$(function  () {
    //获取学科
    $.post(
        ipurl+'/subject/get',
        function(result) {
            if(result.code == 200){
                var classlist = result.data.results;
                var classhtml = '';
                for(var i=0;i<classlist.length;i++){
                    classhtml+='<tr>';
                    classhtml+='<td>';
                    classhtml+=classlist[i].ID;
                    classhtml+='</td>';
                    classhtml+='<td>';
                    classhtml+=classlist[i].name;
                    classhtml+='</td>';
                    classhtml+='</td>';
                    classhtml+='<td class="td-manage">';
                    classhtml+='<a title="编辑" href="javascript:;" onclick="subject_edit('+"'"+'编辑'+"'"+','+"'"+'msub-edit.html'+"'"+','+classlist[i].ID+','+classlist[i].name+','+'500'+','+'510'+')"  class="ml-5" style="text-decoration:none">';
                    classhtml+='<i class="layui-icon">&#xe642;</i>';
                    classhtml+='</a>';
                    classhtml+='<a title="删除" href="javascript:;" onclick="subject_del(this,'+classlist[i].ID+')"  style="text-decoration:none">';
                    classhtml+='<i class="layui-icon">&#xe640;</i>';
                    classhtml+='</a>';
                    classhtml+='</td>';
                    classhtml+='</tr>';
                }
                $("#menubody").html(classhtml);
            }
        }
    );
})

function menugo(address){
    $("#rightcontent").attr('src',address);
}


function subject_add(title,url,w,h){
    x_admin_show(title,url,w,h);
}
// 班级-编辑
function subject_edit (title,url,id,name,w,h) {
    $.cookie("suid", id, { expires: 1 });
    $.cookie("suname", name, { expires: 1 });
    x_admin_show(title,url,w,h); 
}
/*班级-删除*/
function subject_del(obj,id){
    layer.confirm('确认要删除吗？',function(index){
        //发异步删除数据
        $(obj).parents("tr").remove();
        layer.msg('已删除!',{icon:1,time:1000});
        $.post(
            ipurl+'/subject/del',
            {
              ID: id
            },
            function(result) {
              console.log(result);
                // layer.open({
                //     content: '添加成功',
                //     end: function(index, layero){
                     
                //     }
                // });
            }
      );
    });
}
